<?php
class Website
{
    public static function create_link($url, $text, $id = "")
    {
      return "<a href='".BASE_URL."/$url' class='$id' title='$text'>$text</a>";
    }

    public static function selection($label, $name, $data, $current = '', $css='')
    {
      $html  = "\n<label for='$name'$css>$label</label>";
      $html .= "\n<select name='$name'>";

      if (empty($current))
      {
        foreach ($data as $i)
          $html .= "\n<option>$i</option>";
      }
      else
      {
        foreach ($data as $i)
        {
          $selected = ($i == $current) ? 'selected' : '';
          $html .= "\n<option $selected>$i</option>";
        }
      }

      return $html . "\n</select>";
    }

    public static function my_format($number)
    {
      return $number < 10 ? "00".$number : ($number < 100 ? "0".$number : $number); 
    }

    public static function week_format($number)
    {
      return $number < 10 ? ltrim($number, '0') : $number; 
    }

    public static function un_format($number)
    {
      return ltrim($number, '0');
    }

    public static function message_spots_left($taken)
    {
      $max  = Les::get_max_deelnemers();
      $left = $max - $taken;
      $msg  = $left == 0 ? "is geen plek" : ($left == 1 ? "is nog &#233;&#233;n plek" : "zijn nog $left plekken");

      echo "\n<div id='message'>\n<h3>Er $msg over</h3>\n</div>";
    }
  }
  
?>